//Test ClsCreateQuoteFromOpportunity
@isTest (seeAllData=true)
private class Test_ClsCreateQuoteFromOpportunity
{
    static testMethod void myUnitTest() 
    {
      test.startTest();
      
      
      Account account = new Account();
      account.Name = 'Ahmed Adel' ;
      insert account ;
      
      Opportunity opportunity = new Opportunity();
      opportunity.AccountId = account.id ;
      opportunity.StageName = 'Prospecting' ;
      opportunity.CloseDate = system.Today();
      opportunity.Name = 'test' ;
      insert opportunity ;
      
      //Pricebook2 pb = new Pricebook2();
      //pb.Name = 'pricebook1' ;      
      //pb.IsActive = true ;
      //insert pb ;
      Pricebook2 pb = [select id from Pricebook2 where IsStandard = true limit 1];
      /*Pricebook2 pb = new Pricebook2();
      pb.Name = 'test PriceBook';
      pb.IsActive = true;
      //pb.IsStandard = true;
      
      insert pb;*/
      
      
      
      Product2 p = new Product2();
      p.Name = 'Test Product' ;
      insert p ;
      
      PricebookEntry pbe = new PricebookEntry(UnitPrice = 90);
      pbe.Pricebook2Id = pb.id ;
      pbe.Product2Id = p.Id ;      
      pbe.UseStandardPrice = false ;
      pbe.IsActive = true ;
      insert pbe ;
      
      OpportunityLineItem l1 = new OpportunityLineItem();
      l1.OpportunityId = opportunity.id ;
      l1.Quantity = 90 ;
      l1.TotalPrice = 890 ;
      l1.PricebookEntryId = pbe.Id ;
      insert l1 ;
      
      
      
      ApexPages.currentPage().getParameters().put('oppid', opportunity.id);
      ApexPages.currentPage().getParameters().put('Name', 'Test2');
      
      Contact contact1 = new Contact(Email = 'test@CC.com' , Fax = '1212' , Phone = '23232');
      contact1.FirstName = 'Ahmed' ;
      contact1.LastName = 'Ahmed1' ;
      insert contact1 ;
      
      Quote quote = new Quote();
      quote.name = 'test' ;
      quote.OpportunityId = opportunity.id ;
      quote.ContactId = contact1.id ;
      insert quote;
      
      ApexPages.StandardController quoteStandardController = new ApexPages.StandardController(quote);      
      ClsCreateQuoteFromOpportunity con = new ClsCreateQuoteFromOpportunity(quoteStandardController);
      con.quoteObject = quote.clone(false);
      //con.oppObject = opportunity;
      con.opportunityId = opportunity.id;
      con.saveQuoteMethod();
      con.pullingContactFieldMethod();
      con.cancelQuoteMethod();
      
      
      
      //Quote quote1 = new Quote();      
      //ApexPages.StandardController quoteStandardController1 = new ApexPages.StandardController(quote1);      
      //ClsCreateQuoteFromOpportunity con1 = new ClsCreateQuoteFromOpportunity(quoteStandardController1);
      //con1.saveQuoteMethod();
      
      
      test.stopTest();
    }
}